# -*- coding: utf-8 -*-

"""
@File    : 03_读取栅格像元坐标.py
@Author  : fungis@163.com
@Time    : 2022/09/17 23:32
@notice  :
"""
import numpy as np
from osgeo import gdal

if __name__ == '__main__':
    filePath = r'./data-use/tif/NDVI_201405_bm.tif'  # 输入你的栅格数据
    dataset = gdal.Open(filePath)
    # 打开波段1（注意:用索引1，而不是0，来获取第一个波段）
    band = dataset.GetRasterBand(1)
    array = band.ReadAsArray()
    # np.savetxt(r'./results/test221012.01.txt', array, encoding='gbk', fmt='%d', delimiter=',')  # 取整数，用,号分隔
    np.savetxt(r'./results/test221012.02.txt', array, encoding='gbk', delimiter=',')
